<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/static/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>箱号录入</title>
<base href="<%=basePath%>">

<link rel="stylesheet" href="static/ace/css/ace.css"
	class="ace-main-stylesheet" id="main-ace-style" />
<script type="text/javascript"
	src="../plugins/websocketInstantMsg/ext4/ext-all-debug.js"></script>
<script type="text/javascript" src="static/js/jquery-1.7.2.js"></script>
<script type="text/javascript"
	src="../plugins/websocketInstantMsg/ext4/locale/ext-lang-zh_CN.js"></script>
<link rel="stylesheet" type="text/css"
	href="../plugins/websocketInstantMsg/ext4/resources/css/ext-all.css" />
</head>
<body>
<div id="div1"></div>
<div id="div"></div>
<div id="div3"></div>
<div id="div2"></div>


</body>

<script type="text/javascript">

Ext.onReady(function () {
    var store = Ext.create('Ext.data.Store', {
        fields: ["ID","BILL_CODE","LADING_BILL_CODE","BOX_TYPE_CONFIRM","CONTAINER_OWNER","BOAT_NAME","BOAT_VOYAGE_NAME","RIVER_PORT",
                 "RIVER_UNLOAD","PORT_DISCHARGE","ESTIMATE_TIME","BUSINESS_TYPE","SALER_NAME","ENCASEMENT_METHOD","BILL_INPUTER","TRANSPORT_CLAUSE",
                "SMALLBOX_NUM","BIGBOX_NUM", "CHINESE_NAME","GOODS_NUM","PACK_TYPE","GOODS_GROSS_WEIGHT","VOLUME","GOODS_TYPE","SHIPPER_NAME",
                "CONTAINER_NO","FORWARDER_CUSTOMER_SERVICE","SHIPPER_NUM","CREATE_TIME","SEAL_NO","BOX_REQUIREMENT","CREATE_TIME"],
        pageSize:15,  //页容量多少条数据
        //是否在服务端排序 （true的话，在客户端就不能排序）
        remoteSort: false,
        remoteFilter: true,
        proxy: {
            type: 'ajax',
            url: '../number/list',
            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                type: 'json', //返回数据类型为json格式
                root: 'result.list',  //数据
                totalProperty: 'result.total' //数据总条数
            }
        },
        sorters: [{
			property: 'ordeId',
			direction: 'desc'
		}],
        autoLoad: true  //即时加载数据
       // autoLoad:{start:0,limit:3}
    });
    
    
//新建的列表
    var grid = Ext.create('Ext.grid.Panel', {
    renderTo: "div",
    id:'grid',
    store: store,
    height: 350,
    width:"100%",
    selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"single", allowDeselect: true, showHeaderCheckbox:false}),
   // selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"SIMPLE"}),
    //selModel: { selType: 'checkboxmodel' },   //选择框
    columns: [                    
                  { text: 'ID', dataIndex: 'ID',  maxWidth: 120 ,hidden:true},
                  { text: '进仓编号', dataIndex: 'BILL_CODE',  maxWidth: 180 },
                  { text: '提单编号', dataIndex: 'LADING_BILL_CODE', align: 'left', minWidth: 80 },
                  { text: '箱型确定', dataIndex: 'BOX_TYPE_CONFIRM', maxWidth: 280, align: 'left' }, 
                  { text: '放箱要求', dataIndex: 'BOX_REQUIREMENT',  maxWidth: 80, align: 'left' },
                  { text: '箱主', dataIndex: 'CONTAINER_OWNER', maxWidth: 80, align: 'left' },
                  { text: '船名', dataIndex: 'BOAT_NAME', maxWidth: 280, align: 'left' },
                  { text: '航次',dataIndex: 'BOAT_VOYAGE_NAME',  maxWidth: 80, align: 'left' },
                  { text: '江船起运港', dataIndex: 'RIVER_PORT', maxWidth: 80, align: 'left' },
                  { text: '江船卸区', dataIndex: 'RIVER_UNLOAD', maxWidth: 80, align: 'left' },
                  { text: '目的港', dataIndex: 'PORT_DISCHARGE', maxWidth: 80, align: 'left' },
                  { text: '放箱时间', dataIndex: 'ESTIMATE_TIME', maxWidth: 280, align: 'left' },
                  { text: '贸易类型', dataIndex: 'BUSINESS_TYPE', maxWidth: 80, align: 'left' },
                  { text: '业务员', dataIndex: 'SALER_NAME', maxWidth: 80, align: 'left' },
                  { text: '装箱方式',dataIndex: 'ENCASEMENT_METHOD',  maxWidth: 80, align: 'left' },
                  { text: '接单时间', dataIndex: 'CREATE_TIME', maxWidth: 150, align: 'left' },
                  { text: '操作员', dataIndex: 'BILL_INPUTER', maxWidth: 80, align: 'left' },
                  { text: '运输条款', dataIndex: 'TRANSPORT_CLAUSE', maxWidth: 80, align: 'left' },
                  { text: '小箱', dataIndex: 'SMALLBOX_NUM', maxWidth: 80, align: 'left' },
                  { text: '大箱', dataIndex: 'BIGBOX_NUM', maxWidth: 80, align: 'left' },
                  { text: '中文品名',dataIndex: 'CHINESE_NAME',  maxWidth: 80, align: 'left' },
                  { text: '件数', dataIndex: 'GOODS_NUM', maxWidth: 80, align: 'left' },
                  { text: '包装类别', dataIndex: 'PACK_TYPE', maxWidth: 80, align: 'left' },
                  { text: '毛重', dataIndex: 'GOODS_GROSS_WEIGHT', maxWidth: 80, align: 'left' },
                  { text: '总体积', dataIndex: 'VOLUME', maxWidth: 80, align: 'left' },
                  { text: '货物种类', dataIndex: 'GOODS_TYPE', maxWidth: 80, align: 'left' },
                  //{ text: '装船期限',  maxWidth: 80, align: 'left' },
                  { text: '委托单位',  dataIndex: 'SHIPPER_NAME', maxWidth: 80, align: 'left' },
                  { text: '箱号',  dataIndex: 'CONTAINER_NO', maxWidth: 80, align: 'left' },
                  { text: '封号',  dataIndex: 'SEAL_NO', maxWidth: 80, align: 'left' },
                  { text: '货代客服',  dataIndex: 'FORWARDER_CUSTOMER_SERVICE', maxWidth: 80, align: 'left' },
                  { text: '托运人自编号',  dataIndex: 'SHIPPER_NUM', maxWidth: 80, align: 'left' },
                  
               ],
    bbar: [{
        xtype: 'pagingtoolbar',
        store: store,
        displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
        emptyMsg: "没有数据",
        beforePageText: "当前页",
        afterPageText: "共{0}页",
        displayInfo: true ,
       // pageSize:1
    }],
   
     tbar:[
//      {text:'新增',iconCls:'a_add',handler:showAlert},"-",
//      {text:'编辑',iconCls:'a_edit2',handler:showAler},
//      {text:'删除',iconCls:'a_edit2',handler:showAle}
], 
listeners: {  
	'cellclick':function(grid,rowIndex,columnIndex,e ){ 
		 var rs=grid.getSelectionModel().getSelection();//获取选中的一行的值
	     Ext.each(rs,function(){
	    	 var billcode=this.get("BILL_CODE"); //托单编号
	    	// alert(billcode)
	    	 Ext.getCmp('tuodan').setValue(billcode);//给文本框赋值
	    	
	    	 var LADINGCODE=this.get("LADING_BILL_CODE"); //提单号
	    	// alert(LADINGCODE)
	    	 Ext.getCmp('tidan').setValue(LADINGCODE);//给文本框赋值
	    	 
	    	 var CONTAINERNO=this.get("CONTAINER_NO"); //箱号
	    	// alert(CONTAINERNO)
	    	 Ext.getCmp('xianghao').setValue(CONTAINERNO);//给文本框赋值
	    	
	    	 var SEAL_NO=this.get("SEAL_NO");//封号
	    	// alert(SEAL_NO)
	    	 Ext.getCmp('fegnhao').setValue(SEAL_NO);//给文本框赋值
	    	 
	    	 var CHINESE_NAME=this.get("CHINESE_NAME");//中文品名
	    	 //alert(CHINESE_NAME)
	    	 Ext.getCmp('zhongwen').setValue(CHINESE_NAME);//给文本框赋值
	    	 
	    	 var GOODS_NUM=this.get("GOODS_NUM");//件数
	    	// alert(GOODS_NUM)
	    	 Ext.getCmp('jianshu').setValue(GOODS_NUM);//给文本框赋值
	    	 
	    	 var GOODS_GROSS_WEIGHT=this.get("GOODS_GROSS_WEIGHT");//毛重
	    	// alert(GOODS_GROSS_WEIGHT)
	    	 Ext.getCmp('maozhong').setValue(GOODS_GROSS_WEIGHT);//给文本框赋值
	    	 
	    	 var store = Ext.getCmp('grid1').getStore();
	    	 store.on('beforeload', function(store,options) {  
		            var new_params1 = {  
		            		BILL_CODE : billcode,
		            		LADING_BILL_CODE:LADINGCODE
		            };  
		 
		            Ext.apply(store.proxy.extraParams,new_params1);  
		        });  
	    	       store.load(); 
	     })
	}   
	}  
});
    
        var store2 = Ext.create('Ext.data.Store', {
						        fields: ["ID","SHIP_NAME"],
						        remoteSort: false,
						        remoteFilter: true,
						        proxy: {
						            type: 'ajax',
						            url: '../number/ship',
						            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
						                type: 'json', //返回数据类型为json格式
						                root: 'rows2',  //数据
						                totalProperty: 'tota2' //数据总条数
						            }
						        },
						        sorters: [{
									property: 'ordeId',
									direction: 'desc'
								}],
						        autoLoad: true  //即时加载数据
						    });
						    
        var store3 = Ext.create('Ext.data.Store', {
	        fields: ["ID","VOYAGE_NUMBER"],
	        remoteSort: false,
	        remoteFilter: true,
	        proxy: {
	            type: 'ajax',
	            url: '../number/vo',
	            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
	                type: 'json', //返回数据类型为json格式
	                root: 'rows3',  //数据
	                totalProperty: 'tota3' //数据总条数
	            }
	        },
	        sorters: [{
				property: 'ordeId',
				direction: 'desc'
			}],
	        autoLoad: true  //即时加载数据
	    });
         
        //日期控件
        function convertDate(val) {
				return Ext.util.Format.date(new Date(val), 'Y-m-d');
			}
        //新建查询列表
		var c1 = Ext.create('Ext.container.Container', {
			layout : 'column',
			 width:'100%',
			 height:110,
			defaults : {
				labelAlign : 'left',
				labelWidth : 60
			},
			items : [
					{
						xtype : 'textfield',
						name : 'LADING_BILL_CODE',
						id:'bookingType',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '托单编号',
						emptyText:'托单编号'
					},
					{
						xtype : 'textfield',
						name : 'COMPANY_NAME',	
						columnWidth : 1 / 4,
						padding : '5px',
						id:'companyName',
						fieldLabel : '提单号',
						emptyText:'提单号'
					},
					{
						xtype : 'textfield',
						name : 'SPELL_CODE',
						id:'spellCode',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '箱主',
						emptyText:'箱主'
					},
					{
						xtype : 'textfield',
						name : 'RIVER_PORT',
						id:'riverPort',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '起运港',
						emptyText:'起运港'
					},
					{
						xtype : 'combo',
						id:'a',
						name : 'BOAT_NAME',						
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '船名',
						emptyText:'--请选择--',
						store : store2,
						valueField: 'ID',
						displayField:'SHIP_NAME',
						listeners : { //监听该下拉列表的选择事件
									select : function(combo, record, index) {
							               var shipID = Ext.getCmp('a').getValue();
 							                //alert(shipID);
						         
						 Ext.Ajax.request({
			     			 url: '../number/vo',
								params : {
									SHIP_NAME_ID:shipID
								},
								method : 'POST',
								success : function(response) {
									
			                          var respText = Ext.decode(response.responseText);
                                  //调用文本域的方法，设置它的值~
        							Ext.getCmp('txt').setValue(respText.rows3[0].VOYAGE_NUMBER);
									store3.load();
								},
							});
						
						
							            }
							        }
						    
					},
					{
						xtype : 'textfield',
						name:'BOAT_VOYAGE_NAME',
						id:"txt",
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '航次',
						emptyText:'--请选择船名--',
						store : store3,
						//readOnly:true,
						
					},
					{
						xtype : 'textfield',
						name : 'CONTAINERNO',
						id:'containerno',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '箱号',
						emptyText:'箱号',
					},
					{
						xtype : 'textfield',
						name : 'FORWARDER_CUSTOMER_SERVICE',
						id:'forwarder',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '货代客服',
						emptyText:'货代客服',
					},
					{
						xtype : 'textfield',
						name : 'SHIPPER_NUM',
						id:'shippeNum',
						columnWidth : 1 / 4,
						padding : '5px',
						fieldLabel : '托运人自编号',
						emptyText:'托运人自编号',
					},
// 					{
// 						xtype : 'datefield',
// 						columnWidth : 1 / 4,
// 						padding : '5px',
// 						fieldLabel : '船期起始时间',
// 					    emptyText:'船期起始时间',
					    	
// 					},
// 					{
// 						xtype : 'datefield',
// 						name : 'SPELL_CODE',
// 						columnWidth : 1 / 4,
// 						padding : '5px',
// 						fieldLabel : '船期截至时间',
// 						emptyText:'船期截至时间',
// 					},
					
					{
						xtype : "button",
						padding : '7px',
						text : '查询',
						handler : function() {
							//alert("00")
							var BILL_CODE = Ext.getCmp('bookingType').getValue();//托单编号
							//alert(BILL_CODE)
							var LADING_BILL_CODE = Ext.getCmp('companyName').getValue(); //提单编号
							//alert(LADING_BILL_CODE)
							var CONTAINER_OWNER = Ext.getCmp('spellCode').getValue();//箱主
							//alert(CONTAINER_OWNER)
                            var RIVER_PORT=Ext.getCmp('riverPort').getValue();//江船起运港
                           // alert(RIVER_PORT)
                            var BOAT_NAME=Ext.getCmp('a').getRawValue();//江船名
                           // alert(BOAT_NAME)
                            var BOAT_VOYAGE_NAME=Ext.getCmp('txt').getValue();//江船航次
                           // alert(BOAT_VOYAGE_NAME)
                            var CONTAINERNO=Ext.getCmp('containerno').getValue();//箱号
                           // alert(CONTAINERNO)
                            var FORWARDER_CUSTOMER_SERVICE=Ext.getCmp('forwarder').getValue();//贷款客服
                           // alert(FORWARDER_CUSTOMER_SERVICE)
                            var SHIPPER_NUM=Ext.getCmp('shippeNum').getValue();//托运人自编号
                            //alert(SHIPPER_NUM)
							var store = Ext.getCmp('grid').getStore();						
							store.on('beforeload', function(store, options) {
								var new_params = {
									BILL_CODE:BILL_CODE,
									LADING_BILL_CODE : LADING_BILL_CODE,
									CONTAINER_OWNER:CONTAINER_OWNER,
									RIVER_PORT:RIVER_PORT,
									BOAT_NAME:BOAT_NAME,
									BOAT_VOYAGE_NAME :BOAT_VOYAGE_NAME,
									CONTAINERNO:CONTAINERNO,
									FORWARDER_CUSTOMER_SERVICE:FORWARDER_CUSTOMER_SERVICE,
									SHIPPER_NUM :SHIPPER_NUM
								};
								Ext.apply(store.proxy.extraParams, new_params);
							});
							store.load();
						}
 					}, ]
		
		});
        
	 
	    
           //把查询的列表放进form中
		var form = Ext.create('Ext.form.Panel', {
			renderTo : 'div1',
			id:'myForm',
			 title : '箱号录入',
			frame : true,
			items : [ c1 ],
		
		});
           
		

	});
	
	
/**>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>箱封号信息录入<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
 
  Ext.onReady(function () {
            var store1 = Ext.create('Ext.data.Store', {
                fields: ["ID","BILL_CODE","LADING_BILL_CODE","IS_DIVIDE_BOX","HARBOUR_REPORT_STATE","SUITCASE_STATION_ID",
                         "STATION_NAME","CONTAINER_OWNER","CONTAINER_TYPE","CONTAINER_NUM","SEAL_NO","CUSTOMS_SEAL","PACKAGE_NUM",
                         "GROSS_WEIGHT","CAPACITY","EMPTY_ENTRY_DATE","EMPTY_OUT_DATE","WEIGHT_ENTRY_DATE","WEIGHT_OUT_DATE","OVER_LIMIT",
                         "OVER_HEIGHT","FRONT_OVER","BEHIND_OVER","LEFT_OVER","RIGHT_OVER","TURN_BOX_UNIT","PACKING_METHOD",
                         "IS_LOGISTICS_BOX","IS_SPELL_BOX","IS_EMPTY_BOX","STATUS","CUSTOMS_DECLARATION_NUM"],
                pageSize: 10,  //页容量5条数据
                //是否在服务端排序 （true的话，在客户端就不能排序）
                remoteSort: false,
                remoteFilter: true,
                proxy: {
                    type: 'ajax',
                    url: '../number/sealentry',
                    reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
                        type: 'json', //返回数据类型为json格式
                        root: 'result.list',  //数据
                        totalProperty: 'result.total' //数据总条数
                    }
                },
                sorters: [{
                    //排序字段。
                    property: 'ordeId',
                    //排序类型，默认为 ASC 
                    direction: 'desc'
                }],
                autoLoad: true  //即时加载数据
            });

            var grid1 = Ext.create('Ext.grid.Panel', {
            	id:'grid1',
            renderTo: 'div2',
            store: store1,
            height: 300,
            title : '箱封报关信息录入',
            width:'100%',
           // selModel:Ext.create('Ext.selection.CheckboxModel',{mode:"SIMPLE"}),  //选择框
            selModel: { selType: 'checkboxmodel' },//单选框 
           columns: [                    
                          { text: 'ID', dataIndex: 'ID', align: 'left', maxWidth: 80,hidden:true,locked:true },
                          { text: '托单号', dataIndex: 'BILL_CODE',  maxWidth: 180 ,locked:true},
                          { text: '提单号', dataIndex: 'LADING_BILL_CODE', align: 'left', minWidth: 180,locked:true },
                          { text: '是否分箱', dataIndex: 'IS_DIVIDE_BOX', maxWidth: 80, align: 'left',locked:true },                        
                          { text: '离港报状态', dataIndex: 'HARBOUR_REPORT_STATE', maxWidth: 80,locked:true },
                          { text: '提箱场站', dataIndex: 'STATION_NAME', maxWidth: 80,locked:true},
                          { text: '箱主', dataIndex: 'CONTAINER_OWNER',maxWidth: 80,locked:true},
                          { text: '箱型', dataIndex: 'CONTAINER_TYPE',maxWidth: 80,locked:true},
                          { text: '是否放箱', dataIndex: 'STATUS', maxWidth: 80,locked:true,},
                          { text: '箱号', dataIndex: 'CONTAINER_NUM',maxWidth: 80},
                          { text: '封号', dataIndex: 'SEAL_NO',maxWidth: 180},
                          { text: '海关封', dataIndex: 'CUSTOMS_SEAL',maxWidth: 80},
                          { text: '件数', dataIndex: 'PACKAGE_NUM',maxWidth: 80},
                          { text: '毛重', dataIndex: 'GROSS_WEIGHT',maxWidth: 80},
                          { text: '体积', dataIndex: 'CAPACITY',maxWidth: 80},
                          { text: '报关单号', dataIndex: 'CUSTOMS_DECLARATION_NUM', align: 'left', minWidth: 180,locked:true },
                          { text: '空进', dataIndex: 'EMPTY_ENTRY_DATE',maxWidth: 80},
                          { text: '空出', dataIndex: 'EMPTY_OUT_DATE',maxWidth: 80},
                          { text: '重进', dataIndex: 'WEIGHT_ENTRY_DATE',maxWidth: 80},
                          { text: '超限', dataIndex: 'OVER_LIMIT',maxWidth: 80},
                          { text: '超高', dataIndex: 'OVER_HEIGHT',maxWidth: 80},
                          { text: '前超', dataIndex: 'FRONT_OVER',maxWidth: 80},
                          { text: '后超', dataIndex: 'BEHIND_OVER',maxWidth: 80},
                          { text: '左超', dataIndex: 'LEFT_OVER',maxWidth: 80},
                          { text: '右超', dataIndex: 'RIGHT_OVER',maxWidth: 80},
                          { text: '转箱单位', dataIndex: 'TURN_BOX_UNIT',maxWidth: 80},
                          { text: '装箱方式', dataIndex: 'PACKING_METHOD',maxWidth: 80},
                          { text: '是否物流用箱', dataIndex: 'IS_LOGISTICS_BOX',maxWidth: 80},
                          { text: '是否拼箱', dataIndex: 'IS_SPELL_BOX',maxWidth: 80},
                          { text: '是否空型', dataIndex: 'IS_EMPTY_BOX',maxWidth: 80},
                         
                         
                       ],
            bbar: [{
                xtype: 'pagingtoolbar',
                store: store1,
                displayMsg: '显示 {0} - {1} 条，共计 {2} 条',
                emptyMsg: "没有数据",
                beforePageText: "当前页",
                afterPageText: "共{0}页",
                displayInfo: true                 
            }],
//              listeners: { 'itemclick': function (view, record, item, index, e) {
//                Ext.MessageBox.alert("标题",record.data.cataId);
//             }
           // },
             tbar:[
             {text:'保存',iconCls:'a_add',handler:showAler},
             {text:'取消放箱',iconCls:'a_edit2',handler:showAlert},
             {text:'报关配船导入',iconCls:'a_lock',handler : toImport1,},
             {text:'报关配船报文导入',iconCls:'a_lock',handler : toImport2,},
             {text:'导入',iconCls:'a_lock',handler : toImport,},
             {text:'导出',iconCls:'a_upload',handler: function(){exportFile("numberEntry");}},], 
        });
            
            
            function showAler(){
            	  var reco=grid1.getSelectionModel().getSelection();
            	  if(reco.length==0){
          			Ext.Msg.alert("提示","请选择需要编辑的记录和只能保存取消放箱");return;
          		}
          		if(reco.length>1){
          			Ext.Msg.alert("提示","只能编辑一条记录和取消放箱");return;
          			
          		}
          		 Ext.each(reco,function(){
            	 var STATUS=this.get("STATUS");//取列表里面某一个字段
            	 
            	 // alert(STATUS)
            	 if(STATUS=="否"){
            		 this.set("STATUS","0") //给列表里的某个字段赋值
            	 }
            	 var  STATUS=this.get("STATUS")
            	// alert(STATUS)
            	 var ID=this.get("ID");//取id
            	// alert(ID)
            	 var BILL_CODE=this.get("BILL_CODE");//取列表里的托单编号
            	// alert(BILL_CODE)
            	 var LADING_BILL_CODE=this.get("LADING_BILL_CODE");//去列表里的提单编号
            	 //alert(LADING_BILL_CODE)
            	 var store12 = Ext.getCmp('grid1').getStore();
            	 var store520 = Ext.getCmp('grid').getStore();
            	 Ext.Ajax.request({
         			 url: '../number/save',
    					params : {
    						ID : ID,
    						STATUS : STATUS,	
    						BILL_CODE : BILL_CODE,
    						LADING_BILL_CODE : LADING_BILL_CODE
    					},
    					method : 'POST',
    					success : function() {
    						Ext.MessageBox.alert("保存成功", "保存成功");
    						store520.load();
    						store12.load();
    					},
    				});
          		 })
            	
            }
function showAlert (){
	//alert("00")
      var records=grid1.getSelectionModel().getSelection();
	 if(records.length==0){
			Ext.Msg.alert("提示","请选择需要编辑的记录");return;
		}
		if(records.length>1){
			Ext.Msg.alert("提示","只能编辑一条记录");return;
		}
		 Ext.each(records,function(){
		 var STATUS=this.get("STATUS");//取列表里面某一个字段
		 //Ext.getCmp("STATUS").setValue(STATUS);
		 if(STATUS=="是"){
			this.set("STATUS","否") 
		 }
// 		 var STATUS=this.get("STATUS");//取列表里面某一个字段
// 		 alert(STATUS)
		// grid1.getColumnModel().setHidden(1,true); 
		 // grid1.columns[i].hide();
		 })
      
 }
 
//导出excel
function exportFile (type){
  if(Ext.getCmp('grid1').getSelectionModel().getSelection().length == 0){
	  Ext.MessageBox.alert("提示", "请选择一条记录！");
      return;
  }
  if(Ext.getCmp('grid1').getSelectionModel().getSelection().length > 1){
		Ext.Msg.alert("提示","请选择箱号录入里一条记录");return;
	}
  var BILL_CODE = Ext.getCmp('grid1').getSelectionModel().getSelection()[0].get("BILL_CODE");
  //alert(BILL_CODE)
  var LADING_BILL_CODE = Ext.getCmp('grid1').getSelectionModel().getSelection()[0].get("LADING_BILL_CODE");
 // alert(LADING_BILL_CODE)
  var ID = Ext.getCmp('grid1').getSelectionModel().getSelection()[0].get("ID");//去列表值
 // alert(ID)
  document.location.href="../common/export/exportExcel?exportType="+type+"&BILL_CODE="+BILL_CODE+"&LADING_BILL_CODE="+LADING_BILL_CODE+"&ID="+ID;	
}

//导入excel
function toImport(){
	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length == 0){
		  Ext.MessageBox.alert("提示", "请选择箱号录入里一条记录！");
	      return;
	  }
	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length > 1){
			Ext.Msg.alert("提示","请选择箱号录入里一条记录");return;
		}
    impWin.show();
}
var uploadForm = Ext.create('Ext.form.Panel', {
    items: [
        {
            xtype: 'filefield',
            fieldLabel: '文件上传',
            name:"file",
            labelWidth: 80,
            msgTarget: 'side',
            allowBlank: false,
            emptyText: "请选择上传文件",
            blankText:"请选择上传文件",
            margin: '10,10,10,10',
            anchor: '100%',
            buttonText:'选择文件'
        }],
    buttonAlign:'center'

});


var impWin = Ext.create('Ext.window.Window', {
    title: '封箱号',
    modal : true,
    items: [uploadForm],
    closeAction: 'hide',
    closeable: true,
    iconCls: 'modalWin',
    buttonAlign: 'center',
    buttons: [
        {text: '导入',handler: function() { impSubmit(); }},
        {text: '关闭', handler: function() { impWin.close(); }}
    ]
});

function impSubmit(){
    uploadForm.getForm().submit({
        url:'../number/num',  
        success: function(form, action) {
            var jsonResult = Ext.JSON.decode(action.response.responseText);
            if (jsonResult.success && jsonResult.code == "200") {
                Ext.Msg.alert("提示","导入成功！",function(){
                    store1.reload();
                    impWin.close();
                });
            }else{
                Ext.Msg.alert("提示","导入操作失败，请检查文件内容是否正确！");
            }
        }
    });
}

//报关配船导入excel
function toImport1(){
	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length == 0){
		  Ext.MessageBox.alert("提示", "请选择箱号录入里一条记录！");
	      return;
	  }
	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length > 1){
			Ext.Msg.alert("提示","请选择箱号录入里一条记录");return;
		}
    impWin1.show();
}
var uploadForm1 = Ext.create('Ext.form.Panel', {
    items: [
        {
            xtype: 'filefield',
            fieldLabel: '文件上传',
            name:"file",
            labelWidth: 80,
            msgTarget: 'side',
            allowBlank: false,
            emptyText: "请选择上传文件",
            blankText:"请选择上传文件",
            margin: '10,10,10,10',
            anchor: '100%',
            buttonText:'选择文件'
        }],
    buttonAlign:'center'

});


var impWin1 = Ext.create('Ext.window.Window', {
    title: '封箱号',
    modal : true,
    items: [uploadForm1],
    closeAction: 'hide',
    closeable: true,
    iconCls: 'modalWin',
    buttonAlign: 'center',
    buttons: [
        {text: '导入',handler: function() { isSubmit(); }},
        {text: '关闭', handler: function() { impWin1.close(); }}
    ]
});

function isSubmit(){
    uploadForm1.getForm().submit({
        url:'../number/customs_declaration',  
        success: function(form, action) {
            var jsonResult = Ext.JSON.decode(action.response.responseText);
            if (jsonResult.success && jsonResult.code == "200") {
                Ext.Msg.alert("提示","导入成功！",function(){
                    store1.reload();
                    impWin1.close();
                });
            }else{
                Ext.Msg.alert("提示","导入操作失败，请检查文件内容是否正确！");
            }
        }
    });
}
		
		
//报关配船报文导入excel
function toImport2(){
	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length == 0){
		  Ext.MessageBox.alert("提示", "请选择箱号录入里一条记录！");
	      return;
	  }
	 if(Ext.getCmp('grid').getSelectionModel().getSelection().length > 1){
			Ext.Msg.alert("提示","请选择箱号录入里一条记录");return;
		}
    impWin2.show();
}
var uploadForm2 = Ext.create('Ext.form.Panel', {
    items: [
        {
            xtype: 'filefield',
            fieldLabel: '文件上传',
            name:"file",
            labelWidth: 80,
            msgTarget: 'side',
            allowBlank: false,
            emptyText: "请选择上传文件",
            blankText:"请选择上传文件",
            margin: '10,10,10,10',
            anchor: '100%',
            buttonText:'选择文件'
        }],
    buttonAlign:'center'

});


var impWin2 = Ext.create('Ext.window.Window', {
    title: '封箱号',
    modal : true,
    items: [uploadForm2],
    closeAction: 'hide',
    closeable: true,
    iconCls: 'modalWin',
    buttonAlign: 'center',
    buttons: [
        {text: '导入',handler: function() { Submit(); }},
        {text: '关闭', handler: function() { impWin2.close(); }}
    ]
});

function Submit(){
    uploadForm2.getForm().submit({
        url:'../number/message',  
        success: function(form, action) {
            var jsonResult = Ext.JSON.decode(action.response.responseText);
            if (jsonResult.success && jsonResult.code == "200") {
                Ext.Msg.alert("提示","导入成功！",function(){
                    store1.reload();
                    impWin2.close();
                });
            }else{
                Ext.Msg.alert("提示","导入操作失败，请检查文件内容是否正确！");
            }
        }
    });
}		
//箱型下拉
var xiangxing = Ext.create('Ext.data.Store', {
	fields: ['id', 'name'],
	data : [
        {"id":"", "name":"选择箱型"},
		{"id":"20GP", "name":"20GP"},
		{"id":"40GP", "name":"40GP"},
		{"id":"20FL", "name":"20FL"},
		{"id":"40FL", "name":"40FL"},
		{"id":"40HC", "name":"40HC"},
		{"id":"45HC", "name":"45HC"},
		{"id":"20RF", "name":"20RF"},
		{"id":"40RF", "name":"40RF"},
		{"id":"20FR", "name":"20FR"},
		{"id":"40FR", "name":"40FR"},
		{"id":"20DG", "name":"20DG"},
		{"id":"40DG", "name":"40DG"},	
		{"id":"200T", "name":"200T"},
		{"id":"400T", "name":"400T"},
		{"id":"40TK", "name":"40TK"},
		{"id":"40RH", "name":"40RH"},
		{"id":"40HQ", "name":"40HQ"},
		
		
	]
});
//想状态下拉
var xiangzhuangtai = Ext.create('Ext.data.Store', {
	fields: ['id', 'name'],
	data : [
        {"id":"", "name":"选择箱型状态"},
		{"id":"E", "name":"整箱"},
		{"id":"L", "name":"拼箱"},
		{"id":"A", "name":"空箱"},
		
	]
});

var c2 = Ext.create('Ext.container.Container', {
	layout : 'column',
	 width:'100%',
	 height:80,
	defaults : {
		labelAlign : 'left',
		labelWidth : 60
	},
	items : [
			{
				xtype : 'textfield',
				name : 'BILL_CODE',
				id:'tuodan',
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '托单编号',
				emptyText:'请选择箱号录入中的记录',					
			    readOnly: true,
		        allowBlank: false,
			},{
				xtype : 'textfield',
				name : 'LADING_BILL_CODE',
				id:'tidan',
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '提单编号',
				emptyText:'提单编号'
			},{
				xtype : 'textfield',
				name : 'CONTAINER_NO',
				id:'xianghao',
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '箱号',
				emptyText:'请输入箱号',
			},

			{
				xtype : 'textfield',
				name : 'SEAL_NO',
				id:'fegnhao',
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '封号',
				emptyText:'请输入封号',
			},
			{
				xtype : 'textfield',
				name : 'CHINESE_NAME',
				id:'zhongwen',
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '中文品名',
				emptyText:'请输入中文品名',
				 readOnly: true,
			        allowBlank: false,
			},
			{
				xtype : 'textfield',
				name : 'GOODS_NUM',
				id:'jianshu',
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '件数',
				emptyText:'请输入件数',
			},
			{
				xtype : 'textfield',
				name : 'GOODS_GROSS_WEIGHT',
				id:'maozhong',
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '毛重',
				emptyText:'请输入毛重',
			},
			{
				xtype : 'combo',
				id:'xiangxing',
				name : 'BOX_TYPE_CONFIRM',						
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '箱型',
				emptyText:'--请选择--',
				store : xiangxing,
				valueField: 'id',
				displayField:'name',
				editable: false, 	
				//allowBlank:false,
				    
			},
			{
				xtype : 'combo',
				name:'dasd',
				id:"xiangzhuangtai",
				columnWidth : 1 / 5,
				padding : '5px',
				fieldLabel : '箱状态',
				emptyText:'--请选择--',
				store : xiangzhuangtai,
				valueField: 'id',
				displayField:'name',
				editable: false,
				//readOnly:true,
				
			},{
				xtype : "button",
				padding : '7px',
				text : '保存',
				handler : function() {
					var xiangxing = Ext.getCmp("xiangxing").getRawValue();
		     		if(xiangxing==""){
		     			alert("箱型不能为空")
		     			return  
		     		}
		     		var xiangzhuangtai = Ext.getCmp("xiangzhuangtai").getRawValue();
		     		if(xiangzhuangtai==""){
		     			alert("箱状态不能为空")
		     			return  
		     		}
					var name = Ext.getCmp("tidan").getValue();
		     		if(name==""){
		     			alert("提单编号不能为空")
		     			return  
		     		}
		     		var q = Ext.getCmp("xianghao").getValue();
		     		if(q==""){
		     			alert("箱号不能为空")
		     			return  
		     		}
		     		var fegnhao = Ext.getCmp("fegnhao").getValue();
		     		if(fegnhao==""){
		     			alert("封号不能为空")
		     			return  
		     		}
		     		var jianshu = Ext.getCmp("jianshu").getValue();
		     		if(jianshu==""){
		     			alert("件数不能为空")
		     			return  
		     		}
		     		var maozhong = Ext.getCmp("maozhong").getValue();
		     		if(maozhong==""){
		     			alert("毛重不能为空")
		     			return  
		     		}
		     		
					var BILL_CODE = Ext.getCmp('tuodan').getValue();//托单编号  //去文本框里面的值
					alert(BILL_CODE)
					
					var LADING_BILL_CODE = Ext.getCmp('tidan').getValue(); //提单编号
					alert(LADING_BILL_CODE)
					var CONTAINER_NO = Ext.getCmp('xianghao').getValue();//箱号
					alert(CONTAINER_NO)
                    var SEAL_NO=Ext.getCmp('fegnhao').getValue();//封号
                    alert(SEAL_NO)
                    var CHINESE_NAME=Ext.getCmp('zhongwen').getValue();//中文品名
                    alert(CHINESE_NAME)
                    var GOODS_NUM=Ext.getCmp('jianshu').getValue();//件数
                    alert(GOODS_NUM)
                    var GOODS_GROSS_WEIGHT=Ext.getCmp('maozhong').getValue();//毛重
                    alert(GOODS_GROSS_WEIGHT)
                    var BOX_TYPE=Ext.getCmp('xiangxing').getValue();//箱型
                    alert(BOX_TYPE)
                    var dasd=Ext.getCmp('xiangzhuangtai').getValue();//想状态
                    alert(dasd)
					var store = Ext.getCmp('grid1').getStore();	
                    var store1 = Ext.getCmp('grid').getStore();		
                    Ext.Ajax.request({
            			 url: '../number/Preservation ',
       					params : {
       						BILL_CODE : BILL_CODE,//托单编号
							LADING_BILL_CODE : LADING_BILL_CODE,//提单标号
							CONTAINER_NO : CONTAINER_NO,//箱号
							SEAL_NO : SEAL_NO,//封号
							CHINESE_NAME : CHINESE_NAME,//中文品名
							GOODS_NUM : GOODS_NUM, //件数
							GOODS_GROSS_WEIGHT : GOODS_GROSS_WEIGHT,//毛重
							BOX_TYPE : BOX_TYPE,//箱型
							dasd : dasd//箱状态
       					},
       					method : 'POST',
       					success : function() {
       						Ext.MessageBox.alert("保存成功", "保存成功");
                               
       						store.load();
       						store1.load();
       					},
       				});
					
				}
				},


			]
 

});

//把查询的列表放进form中
var form1 = Ext.create('Ext.form.Panel', {
	renderTo : 'div3',
	id:'add',
	 title : '箱封号信息录入',
	frame : true,
	items : [ c2 ],

});

}); 
 
</script>



</html>